package com.example.project.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.example.project.entity.Carousel;
import com.example.project.mapper.CarouselMapper;

/**
 * 轮播图Controller
 *
 * @author changyao
 * @date 2024-12-23
 */
@RestController
@RequestMapping("/project/carousel")
public class CarouselController
{
    @Autowired
    private CarouselMapper carouselMapper;

    /**
     * 查询轮播图列表
     */
    @GetMapping("/list")
    public List<Carousel> list()
    {
        QueryWrapper<Carousel> queryWrapper=new QueryWrapper<>();
        return carouselMapper.selectList(queryWrapper);
    }




    /**
     * 获取轮播图详细信息
     */
    @PostMapping("/detil")
    public Carousel getInfo(@RequestBody Carousel carousel)
    {
        return carouselMapper.selectById(carousel);
    }


    /**
     * 新增轮播图
     */
    @PostMapping("/add")
    public int add(@RequestBody Carousel carousel)
    {
        return carouselMapper.insert(carousel);
    }

    /**
     * 修改轮播图
     */
    @PostMapping("/edit")
    public int edit(@RequestBody Carousel carousel)
    {
        return carouselMapper.updateById(carousel);
    }

    /**
     * 删除轮播图
     */
	@PostMapping("/del")
    public int remove(@RequestBody Carousel carousel)
    {
        return carouselMapper.deleteById(carousel);
    }
}
